import React, { Component } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import * as actions from '@/app/Models/actions'
import Wrap from '@/app/Hoc/Wrap'
import { Button } from 'antd-mobile'
import './style.scss'


@connect(
    state => state.auth || {},
    dispatch => bindActionCreators(actions, dispatch)
)
class User extends Component {
    handleLogout = () => {
        this.props.logout()
    }

    render() {
        const {userInfo} = this.props

        return (
            <Wrap>
                <h2 class="user-title">这里是用户中心首页</h2>
                <ul>
                    <li>用户名: {userInfo.name}</li>
                    <li>用户类别: {userInfo.type}</li>
                </ul>
                <Button 
                    type="primary" 
                    onClick={this.handleLogout}
                >登出按钮</Button>
            </Wrap>
        )
    }
}

export default User